import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import commonjs from "rollup-plugin-commonjs";
import externalGlobals from "rollup-plugin-external-globals";
const { resolve } = require("path");
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": resolve(__dirname,'./src'),    },
  },
  server: {
    host: "0.0.0.0",
  },
  base: "./",
  build: {
    rollupOptions: {
      assetsDir: "./assets",
      input: {
        main: resolve(__dirname, "index.html"),
        Home: resolve(__dirname, "./src/pages/Home/Home.html"),
        ListPage: resolve(__dirname, "./src/pages/ListPage/ListPage.html"),
        scenic: resolve(__dirname, "./src/pages/scenic/scenic.html"),
        search: resolve(__dirname, "./src/pages/search/search.html"),
        upload_policy: resolve(__dirname, "./src/pages/upload_policy/upload_policy.html"),
        upload_volunteer: resolve(__dirname, "./src/pages/upload_volunteer/upload_volunteer.html"),
        upload_act: resolve(__dirname, "./src/pages/upload_act/upload_act.html"),
        volunteerDetail:resolve(__dirname, "./src/pages/volunteerDetail/volunteer.html"),
        Forum:resolve(__dirname, "./src/pages/Forum/Forum.html"),
        detail:resolve(__dirname, "./src/pages/detail/ListPage.html"),
        detailActive:resolve(__dirname, "./src/pages/detailActive/ListPage.html"),
        ListVolunteer:resolve(__dirname, "./src/pages/ListVolunteer/ListVolunteer.html"),
        change_msg:resolve(__dirname, "./src/pages/change_msg/change_msg.html"),
        detailperson:resolve(__dirname, "./src/pages/detail-person/detail-person.html"),
        detailorg:resolve(__dirname, "./src/pages/detail-org/detail-org.html")
      },
      external: ["vue", "element-plus", "vue-demi"],
      plugins: [
        externalGlobals({
          vue: "Vue",
          "element-plus": "ElementPlus",
          // 👇 配置 vue-demi 全局变量 👇
          "vue-demi": "VueDemi",
        }),
      ],
    },
  },
});
